package com.onec.service.thread.producer;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class SafeDataBuffer<T> {


  public BlockingQueue<T> blockingQueue = new LinkedBlockingQueue<>();

  public AtomicInteger amount = new AtomicInteger(1);

  /**
   * add
   */
  public synchronized void add(T t) {
    blockingQueue.add(t);
    System.out.println("新增完成");
    amount.addAndGet(1);
  }

  public synchronized void fetch() {
    boolean t1 = blockingQueue.remove(0);
    return;
  }


}
